package com.btb.adapter.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.btb.adapter.utils.ResponseText;
import com.btb.adapter.vo.request.Fish;
import com.btb.adapter.vo.request.FishPart;
import com.btb.adapter.vo.request.FishUpChain;
import com.btb.adapter.vo.request.Hero;
import com.btb.adapter.vo.request.HeroUpChain;
import com.btb.adapter.vo.request.OffChainRequest;
import com.btb.adapter.vo.request.PayRequest;
import com.btb.adapter.vo.request.QueryPage;
import com.btb.adapter.vo.request.UpChainQuery;
import com.btb.adapter.vo.request.UpChainResult;

public class GenTest {

	public static void main(String[] args) {
//		upChainQuery();
//		payConfirm();
//		payQuery();
		genOffChainRequest();
	}
	private static void upChainQuery() {
		UpChainQuery query1 = UpChainQuery.builder().id(1)
				.sn("10403010")
				.status("0")
				.transactionHash("0x358cf0091982d769f5dbdbdc6b0ec64ef7580e55fed26482f672889d0cf0a5c7")
				.receiveTimestamp(new Date().getTime())
				.startUpChainTimestamp(new Date().getTime())
				.eventUpChainTimestamp(new Date().getTime())
				.address("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3")
				.gasUsed("0.000001")
				.build();
		UpChainQuery query2 = UpChainQuery.builder().id(1)
				.sn("10403011")
				.status("2")
				.transactionHash("0x5x8cf0091982d7tcf5dbdbdc6b0ec64ef1580e51fed26482f676689d0cf0a5c7")
				.receiveTimestamp(new Date().getTime())
				.startUpChainTimestamp(new Date().getTime())
				.eventUpChainTimestamp(new Date().getTime())
				.address("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3")
				.gasUsed("0.000001")
				.build();
		UpChainResult build = UpChainResult.builder()
				.requestId(UUID.randomUUID().toString())
				.type("hero")
				.list(Arrays.asList(query1,query2))
				.build();
//		ResponseText<UpChainResult> r = ResponseText.<UpChainResult>buildSuccess(build);
//		ResponseText<UpChainResult> r = ResponseText.<UpChainResult>buildSuccess(build);
//		ResponseText<String> buildFail = ResponseText.buildFail("type参数错误");
		QueryPage<UpChainResult> page = QueryPage.<UpChainResult>builder()
				.pageNo(1)
				.pageTotal(10)
				.total(2L)
				.pageSize(20)
				.data(build)
				.build();
		System.out.println(JSON.toJSONString(page));
	}
	public static void payConfirm() {
		PayRequest payRequest = PayRequest.builder()
				.requestId(UUID.randomUUID().toString())
				.transactionHash("0x358cf0091982d769f5dbdbdc6b0ec64ef7580e55fed26482f672889d0cf0a5c7")
				.address("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3")
				.status(Boolean.TRUE)
				.orderId("20210906")
				.type("1")
				.orderPrice("0.001")
				.time(new Date().getTime())
				.build();
		System.out.println(JSON.toJSONString(payRequest));
//		ResponseText<JSONOBJ>
		ResponseText<JSONObject> responseText = new ResponseText<JSONObject>();
		JSONObject object = new JSONObject();
		object.put("requestId", "a51241c8-65a8-40be-a7b0-c7d9e6efa246");
		ResponseText<JSONObject> buildSuccess = ResponseText.buildSuccess(object);
		System.out.println(JSON.toJSONString(buildSuccess));
	}
	public static void payQuery() {
		PayRequest payRequest = PayRequest.builder()
				.requestId(UUID.randomUUID().toString())
				.transactionHash("0x358cf0091982d769f5dbdbdc6b0ec64ef7580e55fed26482f672889d0cf0a5c7")
				.address("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3")
				.status(Boolean.TRUE)
				.orderId("20210906")
				.type("1")
				.orderPrice("0.001")
				.time(new Date().getTime())
				.build();
//		System.out.println(JSON.toJSONString(payRequest));
//		ResponseText<JSONOBJ>
		ResponseText<JSONObject> responseText = new ResponseText<JSONObject>();
		JSONObject object = new JSONObject();
		ResponseText<PayRequest> buildSuccess = ResponseText.buildSuccess(null);
		System.out.println(JSON.toJSONString(buildSuccess));
	}
	public static void main1(String[] args) {
		Hero build1 = Hero.builder()
				.id(1)
				.sn("10000001")
				.heroArea(2)
				.grade(3)
				.cardImage("https://bkimg.cdn.bcebos.com/pic/a1ec08fa513d26974e3a283753fbb2fb4216d8ea.jpeg")
				.name("诸葛亮")
				.season(1)
				.cardTips("源自《三国志·诸葛亮传》中称赞未出茅庐的诸葛亮说：诸葛孔明者,卧龙也。")
				.powerValue(12000000L)
				.productionDate(1630997780241L)
				.build();
		Hero build2 = Hero.builder()
				.id(2)
				.sn("10000002")
				.heroArea(2)
				.grade(3)
				.cardImage("https://bkimg.cdn.bcebos.com/pic/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jpeg")
				.name("刘备")
				.season(1)
				.cardTips("汉昭烈帝刘备（161年－223年6月10日），汉族，字玄德，涿郡涿县（今河北省涿州市）人，西汉中山靖王刘胜之后，蜀汉开国皇帝、政治家")
				.powerValue(12000000L)
				.productionDate(1630997780241L)
				.build();
		Hero build3 = Hero.builder()
				.id(3)
				.sn("10000003")
				.heroArea(2)
				.grade(3)
				.cardImage("https://bkimg.cdn.bcebos.com/pic/yyyyyyyyyyyyyyyy.jpeg")
				.name("张飞")
				.season(1)
				.cardTips("字益德，涿郡（今河北保定涿州市）人，三国时期蜀汉名将")
				.powerValue(14000000L)
				.productionDate(1630997780241L)
				.build();
		List<Hero> list = Arrays.asList(build1, build2, build3);
//		HeroUpChian build = HeroUpChian.builder().owner("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3").list(list).build();
		HeroUpChain build = HeroUpChain.builder().owner("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3").list(Arrays.asList()).build();
		String jsonString = JSON.toJSONString(build);
		System.out.println("jsonString:\t" + jsonString);
		System.out.println(UUID.randomUUID().toString());
	}
	public static void main3(String[] args) {
		Map<String, FishPart> part = new HashMap<String, FishPart>();
		part.put("eye", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(10).build());
		part.put("skinColor", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(20).build());
		part.put("ear", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(30).build());
		part.put("texture", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(40).build());
		part.put("texture", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(10).build());
		part.put("ventralFin", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(30).build());
		part.put("dorsalFin", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(25).build());
		part.put("ventralFin", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(12).build());
		Map<String, FishPart> part1 = new HashMap<String, FishPart>();
		part1.put("eye", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(10).build());
		part1.put("skinColor", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(20).build());
		part1.put("ear", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(30).build());
		part1.put("texture", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(40).build());
		part1.put("texture", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(10).build());
		part1.put("ventralFin", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(30).build());
		part1.put("dorsalFin", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(25).build());
		part1.put("ventralFin", FishPart.builder().no("106001").imgUrl("http://xxxx.com/eye/xxx.jpeg").addition(12).build());
		Fish build = Fish.builder()
				.id(1)
				.sn("10403010")
				.race(1)
				.productionDate(1630997780241L)
				.cardTips("是一种生活在水里的物种,  不会走路").type(1)
				.transactionNum(0L)
				.part(part)
				.build();
		Fish build2 = Fish.builder()
				.id(2)
				.sn("10403011")
				.race(2)
				.productionDate(1630997780241L)
				.cardTips("是一种生活在水里的物种,  不会走路").type(1)
				.transactionNum(10L)
				.part(part1)
				.build();
		List<Fish> asList = Arrays.asList(build, build2);
		FishUpChain upchain = FishUpChain.builder().owner("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3").list(asList).build();
		System.out.println(JSON.toJSONString(upchain));
	}
	public static void genOffChainRequest() {
		OffChainRequest build = OffChainRequest.builder()
				.owner("0xc320b3d9cf5f2a6b32fc615bad1cec0e3649c5a3")
				.list(Arrays.asList(1L,2L,3L,4L,5L,6L,7L,8L,9L,10L))
				.type(1)
				.build();
		System.out.println(JSON.toJSONString(build));
	}
}
